<template>
	<view class="withCash">
		<view class="cell">
			<view class="cellItem">
				<view class="title">单笔提现设置</view>
				<view class="valueList">
					<view class="valItem dis" @click="open(1, data.miniWithdrawalAmount)">
						<view class="valL">最低提现金额</view>
						<view class="valR dis">
							<view class="">{{ data.miniWithdrawalAmount }}</view>
							<view class="icon">
								<up-icon name="arrow-right" color="#969799" size="15"></up-icon>
							</view>
						</view>
					</view>
					<view class="valItem dis" @click="open(2, data.maxWithdrawalAmount)">
						<view class="valL">最高提现金额</view>
						<view class="valR dis">
							<view class="">{{ data.maxWithdrawalAmount }}</view>
							<view class="icon">
								<up-icon name="arrow-right" color="#969799" size="15"></up-icon>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="cell">
			<view class="cellItem">
				<view class="title">风险用户设置</view>
				<view class="valueList">
					<view class="valItem dis" @click="open(3, data.bond)">
						<view class="valL">缴纳保证金金额</view>
						<view class="valR dis">
							<view class="">{{ data.bond }}</view>
							<view class="icon">
								<up-icon name="arrow-right" color="#969799" size="15"></up-icon>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
	<up-modal :title="title" :show="showModal" contentTextAlign="center" confirmButtonShape="circle">
		<view class="slot_content dis">
			<up-number-box v-model="value"></up-number-box>
		</view>
		<template #confirmButton>
			<view class="modalBut dis">
				<view class="custom_btn nodeBut" @click="okDel">取消</view>
				<view class="custom_btn" @click="okAdd">确定</view>
			</view>
		</template>
	</up-modal>
</template>

<script setup>
import { getWithdrawalSetting, setMiniWithdrawalAmount } from '@/config/api.js';
import { ref } from 'vue';
import { onShow, onLoad, onReachBottom } from '@dcloudio/uni-app';
const schoolId = ref(0);
onLoad((options) => {
	schoolId.value = options.schoolId;
	getData();
});
onShow(() => {});

const data = ref({});
const getData = async () => {
	const res = await getWithdrawalSetting(1);
	console.log(res);
	if (res.code == 0) {
		data.value = res.data.withdrawalSetting;
	}
};

// 弹窗
const showModal = ref(false);
const value = ref(0);
const title = ref('修改最低提现金额');
const type = ref(1);
const okDel = () => {
	value.value = 0;
	title.value = '修改最低提现金额';
	showModal.value = false;
};
const okAdd = async () => {
	let datas = {};
	if (type.value == 1) {
		datas = {
			miniWithdrawalAmount: value.value
		};
	} else if (type.value == 2) {
		datas = {
			maxWithdrawalAmount: value.value
		};
	} else if (type.value == 3) {
		datas = {
			bond: value.value
		};
	}
	const res = await setMiniWithdrawalAmount(1, datas);
	console.log(res);
	if (res.code == 0) {
		okDel();
		getData();
	}
	uni.showToast({
		title: res.message,
		icon: 'none'
	});
};
const open = (num, val) => {
	if (num == 1) {
		title.value = '修改最低提现金额';
	} else if (num == 2) {
		title.value = '修改最高提现金额';
	} else if (num == 3) {
		title.value = '修改缴纳保证金金额';
	}
	type.value = num;
	showModal.value = true;
	value.value = val;
};
</script>

<style scoped lang="scss">
.withCash {
	width: 100%;
	.cell {
		width: 100%;
		.cellItem {
			.title {
				padding-left: 20rpx;
			}
			line-height: 70rpx;
			font-size: 26rpx;
			.valueList {
				width: 100%;
				background-color: #fff;
				.valItem {
					justify-content: space-between;
					align-items: center;
					padding: 0 20rpx;
					.valR {
						justify-content: space-between;
						align-items: center;
						color: #969799;
						.icon {
							// padding-top: 5rpx;
						}
					}
				}
			}
		}
	}
}
.slot_content {
	justify-content: center;
	width: 100%;
}
.modalBut {
	align-items: center;
	justify-content: space-around;
	width: 100%;
	.custom_btn {
		width: 40%;
		height: 70rpx;
		line-height: 70rpx;
		border-radius: 35rpx;
		text-align: center;
		color: #fff;
		background-color: #3391e6;
	}
	.nodeBut {
		color: #515151;
		background-color: #f0f0f0;
	}
}
</style>
<style>
page {
	background-color: #f7f7f7;
}
image {
	width: 100%;
	height: 100%;
}
.card {
	margin-bottom: 20rpx;
	background-color: #fff;
	border-radius: 15rpx;
}
.noData {
	width: 100%;
	line-height: 90rpx;
	color: #999;
	text-align: center;
	background-color: #f7f7f7;
}
</style>